package model

import (
	"time"
)

func (m *BookAdmin) TableName() string {
	return "t_book_admins"
}

type BookAdmin struct {
	Id            int64     `gorm:"column:book_admin_id" json:"id"`
	Username      string    `gorm:"column:username;size:32;not null;comment:'用户名'" json:"username"`
	Password      string    `gorm:"column:password;size:32;not null;comment:'密码md5加密'" json:"password"`
	BookAdminName string    `gorm:"column:book_admin_name;size:10;not null;comment:'图书管理员真实姓名'" json:"book_admin_name"`
	Status        int       `gorm:"column:status;not null;comment:'1表示可用 0表示禁用'" json:"status"`
	Email         string    `gorm:"column:email;size:255;not null;comment:'电子邮箱'" json:"email"`
	CreateTime    time.Time `gorm:"column:create_time;not null;comment:'创建时间'" json:"create_time"`
	UpdateTime    time.Time `gorm:"column:update_time;not null;on update CURRENT_TIMESTAMP;comment:'更新时间'" json:"update_time"`
}

// TBooksBorrow represents the t_books_borrow table.
type TBooksBorrow struct {
	BorrowID   int       `gorm:"column:borrow_id;primary_key;autoIncrement:true;comment:借阅表唯一标识"`
	CardNumber int64     `gorm:"column:card_number;not null;comment:借阅证编号 固定11位随机生成 用户和图书关联的唯一标识"`
	BookNumber int64     `gorm:"column:book_number;not null;comment:图书编号 图书唯一标识"`
	BorrowDate time.Time `gorm:"column:borrow_date;not null;comment:借阅日期"`
	CloseDate  time.Time `gorm:"column:close_date;not null;comment:截止日期"`
	ReturnDate time.Time `gorm:"column:return_date;comment:归还日期"`
	CreateTime time.Time `gorm:"column:create_time;not null;comment:创建时间"`
	UpdateTime time.Time `gorm:"column:update_time;not null;onUpdate:CURRENT_TIMESTAMP;comment:更新时间"`
}

// TableName sets the insert table name for this struct type
func (t *TBooksBorrow) TableName() string {
	return "t_books_borrow"
}

// TBookBorrowRule represents the borrowing rules for books.
type TBookBorrowRule struct {
	RuleID           int       `gorm:"column:rule_id;primary_key;autoIncrement:true;comment:借阅规则记录的唯一标识"`
	BookRuleID       int32     `gorm:"column:book_rule_id;not null;comment:借阅规则编号"`
	BookDays         int       `gorm:"column:book_days;not null;comment:借阅天数"`
	BookLimitNumber  int       `gorm:"column:book_limit_number;not null;comment:限制借阅的本数"`
	BookLimitLibrary string    `gorm:"column:book_limit_library;type:varchar(255);not null;comment:限制的图书馆"`
	BookOverdueFee   float64   `gorm:"column:book_overdue_fee;not null;comment:图书借阅后每天逾期费用"`
	CreateTime       time.Time `gorm:"column:create_time;not null;comment:创建时间"`
	UpdateTime       time.Time `gorm:"column:update_time;not null;onUpdate:CURRENT_TIMESTAMP;comment:更新时间"`
}

// TableName sets the insert table name for this struct type.
func (r *TBookBorrowRule) TableName() string {
	return "t_book_rule"
}

type TViolation struct {
	ViolationID      int64     `gorm:"column:violation_id;primaryKey;autoIncrement;comment:'违章表唯一标识'"`        // 违章表唯一标识
	CardNumber       int64     `gorm:"column:card_number;not null;comment:'借阅证编号 11位 随机生成'"`                  // 借阅证编号
	BookNumber       int64     `gorm:"column:book_number;not null;comment:'图书编号 图书唯一标识'"`                     // 图书编号
	BorrowDate       time.Time `gorm:"column:borrow_date;not null;comment:'借阅日期'"`                            // 借阅日期
	CloseDate        time.Time `gorm:"column:close_date;not null;comment:'截止日期'"`                             // 截止日期
	ReturnDate       time.Time `gorm:"column:return_date;comment:'归还日期'"`                                     // 归还日期，可空
	ViolationMessage string    `gorm:"column:violation_message;type:varchar(100);comment:'违章信息'"`             // 违章信息，可空
	ViolationAdminID int64     `gorm:"column:violation_admin_id;not null;comment:'违章信息管理员的id'"`               // 违章信息管理员的id
	CreateTime       time.Time `gorm:"column:create_time;not null;comment:'创建时间'"`                            // 创建时间
	UpdateTime       time.Time `gorm:"column:update_time;not null;onUpdate:CURRENT_TIMESTAMP;comment:'更新时间'"` // 更新时间
}

func (v *TViolation) TableName() string {
	return "t_violation"
}

// Notice 定义了公告表的模型
type Notice struct {
	NoticeID      int       `gorm:"primary_key;autoIncrement;comment:'公告表唯一标识'"`
	NoticeTitle   string    `gorm:"type:varchar(32);not null;comment:'公告题目'"`
	NoticeContent string    `gorm:"type:varchar(255);not null;comment:'公告内容'"`
	NoticeAdminID int64     `gorm:"type:bigint;not null;comment:'发布公告的管理员id'"`
	CreateTime    time.Time `gorm:"not null;comment:'创建时间'"`
	UpdateTime    time.Time `gorm:"not null;onUpdate:CURRENT_TIMESTAMP;comment:'更新时间'"`
}

// TableName 设置表名
func (Notice) TableName() string {
	return "t_notice" // 假设表名为notices
}
